package com.iscas.green.extralindextest.servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * ServletContext监听器
 * 通过WebListener注解自动注册
 */
@WebListener
public class AppServletContextListener implements ServletContextListener {

    private static final Logger log = LoggerFactory.getLogger(AppServletContextListener.class);

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        log.info("========== ServletContext 初始化 ==========");
        log.info("服务器信息: {}", sce.getServletContext().getServerInfo());
        log.info("Servlet API版本: {}.{}", 
                sce.getServletContext().getMajorVersion(),
                sce.getServletContext().getMinorVersion());
        log.info("应用上下文路径: {}", sce.getServletContext().getContextPath());
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        log.info("========== ServletContext 销毁 ==========");
    }
} 